package com.mairuide.bill.methodsanalysis.bszjzy.service;

import com.mairuide.bill.methodsanalysis.bszjzy.pojo.BszizyEntity_YH;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;
import java.util.concurrent.Callable;

/**
 * @Description
 * @auther 刘中华
 * @create 2019-06-20 22:25
 */
public class BszjzyWorkTask implements Callable<List<BszizyEntity_YH>> {
    private String sql;
    private JdbcTemplate jdbcTemplate;
    private String account_rival_card;
    private String account_rival;
    private Integer sign;
    private Integer count;
    public BszjzyWorkTask(String sql,JdbcTemplate jdbcTemplate,String account_rival_card,String account_rival,Integer sign,Integer count) {
        this.sql = sql;
        this.jdbcTemplate = jdbcTemplate;
        this.account_rival_card = account_rival_card;
        this.account_rival = account_rival;
        this.sign = sign;
        this.count = count;
    }
    @Override
    public List<BszizyEntity_YH> call() {
        List<BszizyEntity_YH> bszizyEntities = jdbcTemplate.query(sql,new BeanPropertyRowMapper<BszizyEntity_YH>(BszizyEntity_YH.class));
        for(BszizyEntity_YH b : bszizyEntities){
            b.setACCOUNT_RIVAL_CARD(account_rival_card);
            b.setACCOUNT_RIVAL(account_rival);
            b.setC(bszizyEntities.size());
            b.setSIGN(sign);
            b.setRIVAL_COUNT(count);
        }
        return bszizyEntities;
    }
}
